#include <bits/stdc++.h>
// 2025/07/16
// tag: 
// Author: Forever
using namespace std;
using int64 = int64_t;

int n, a[10001], b[10001], c[10001];

double f(double x){
    double ans = -1e9;
    for (int i = 1; i <= n; i++)
        ans = max(ans, a[i] * x * x + b[i] * x + c[i]);
    return ans;
}

void solve(){
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i] >> b[i] >> c[i];
    double l = 0, r = 1000;
    while (r - l > 1e-9){
        double midl = (l * 2 + r) / 3;
        double midr = (l + r * 2) / 3;
        if (f(midl) < f(midr))
            r = midr;
        else
            l = midl;
    }
    cout << fixed << setprecision(4) << f(l) << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--){
        solve();
    }
    return 0;
}